package com.ybkj.chat.module.mine.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.ybkj.chat.R;
import com.ybkj.chat.base.BaseMvpActivity;
import com.ybkj.chat.manager.ActivityManager;
import com.ybkj.chat.module.dynamic.activity.DynamicDetailActivity;
import com.ybkj.chat.module.dynamic.adapter.DynamicAdapter;
import com.ybkj.chat.module.main.activity.SendPictureActivity;
import com.ybkj.chat.module.main.activity.SendVideoActivity;
import com.ybkj.chat.ui.dialog.DynamicShareDialog;
import com.ybkj.chat.ui.dialog.PpwEditMenu;
import com.ybkj.chat.ui.view.recyclerview.XRecyclerView;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * @author yyj
 * @create 2019-02-27 17:00
 * @Describe
 */
public class MyDynamicActivity extends BaseMvpActivity {
    @BindView(R.id.rv_my_dynamic)
    XRecyclerView rvMyDynamic;
    @BindView(R.id.iv_send_dynamic)
    ImageView ivSendDynamic;

    private PpwEditMenu mPpwMessageMenu;
    private DynamicAdapter mDynamicAdapter;

    @Override
    protected void injectPresenter() {

    }

    @Override
    protected void initTitle() {

    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_my_dynamic;
    }

    @Override
    protected void initView() {
        initPop();
        mDynamicAdapter = new DynamicAdapter(mContext);
        mDynamicAdapter.addData("1");
        mDynamicAdapter.addData("1");
        mDynamicAdapter.addData("1");
        mDynamicAdapter.addData("1");
        mDynamicAdapter.addData("1");
        rvMyDynamic.setAdapter(mDynamicAdapter);
        mDynamicAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
                ActivityManager.gotoActivity(mContext, DynamicDetailActivity.class);
            }
        });
        mDynamicAdapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
            @Override
            public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
                DynamicShareDialog dynamicShareDialog = new DynamicShareDialog(MyDynamicActivity.this, R.style.width_full_dialog);
                dynamicShareDialog.show();
            }
        });
    }

    private void initPop() {
        mPpwMessageMenu = new PpwEditMenu(mContext);
        mPpwMessageMenu.setOnMenuButtonCLickListener(new PpwEditMenu.OnMenuButtonClickListener() {
            @Override
            public void onPictureButtonClick() {
                ActivityManager.gotoActivity(mContext, SendPictureActivity.class);
            }

            @Override
            public void onPhotoButtonClick() {
                ActivityManager.gotoActivity(mContext, SendPictureActivity.class);
            }

            @Override
            public void onVideoButtonClick() {
                ActivityManager.gotoActivity(mContext, SendVideoActivity.class);
            }

            @Override
            public void onMoreButtonClick() {

            }
        });
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
    }

    @OnClick(R.id.iv_send_dynamic)
    public void onViewClicked() {
        mPpwMessageMenu.showAsDropDown(ivSendDynamic, 0, 0);
        mPpwMessageMenu.setBackgroundAlpha(mContext, 0.5f);
    }
}
